package com.yxq.mdt.app.modules.personal.presenter;

import com.yxq.mdt.app.base.BasePresenter;
import com.yxq.mdt.app.modules.personal.bean.MyPersonalBean;
import com.yxq.mdt.app.modules.personal.bean.MyRelationBean;
import com.yxq.mdt.app.modules.personal.model.RelationModel;
import com.yxq.mdt.app.net.ApiModel;

public class RelationPresenter extends BasePresenter<IRelationContract.View, RelationModel> implements IRelationContract.Presenter {

    public RelationPresenter(IRelationContract.View rootView, RelationModel model) {
        super(rootView, model);
    }

    @Override
    public void selectMyRelationList(String userId, int type, int tagType, String searchName, int pageNum, int pageSize) {
        mBaseModel.selectMyRelationList(userId, type, tagType, searchName, pageNum, pageSize, new ApiModel.CommonCallback<MyRelationBean>() {
            @Override
            public void onSuccess(MyRelationBean myRelationBean) {
                mRootView.onLoadSuccess(myRelationBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadFailed();
            }
        });
    }

    public void saveUsersRelation(String userId, int type, int enabled) {
        mBaseModel.saveUsersRelation(userId, type, enabled, new ApiModel.CommonCallback<MyRelationBean>() {
            @Override
            public void onSuccess(MyRelationBean myRelationBean) {
                mRootView.onSaveUserRelationSuccess(myRelationBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onSaveUserRelationFailed();
            }
        });
    }
}
